var Datastore = require('nedb')

function StytemDB(filename) {
    this.db = new Datastore({filename:filename});
    this.db.loadDatabase();
}
StytemDB.prototype.load = function(contact) {
    var self = this;
    return new Promise(function(resolve, reject) {
        self.db.find({}, function(err, docs) {
            if (err) {
                reject(err);
            } else {
                resolve(docs);
            }
        });
    });
}
StytemDB.prototype.add = function(contact) {
    this.db.insert(contact, function(err, newContact) {

    });
}
StytemDB.prototype.remove = function() {
    // console.log(system.new_friends.id)
    this.db.remove({},{multi: true}, function(err, numRemoved) {
        console.log(err)
        console.log(numRemoved)
    });
}
module.exports = StytemDB;